<!DOCTYPE html>
<html lang="zh-CN" data-theme="light">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1" />
  <meta name="generator" content="VuePress 2.0.0-beta.51" />
  <meta name="theme" content="VuePress Theme Hope" />
  <meta property="og:url" content="https://pro.autojs.org/docs/zh/v8/shell.html">
  <meta property="og:site_name" content="Auto.js Pro文档">
  <meta property="og:title" content="shell - Shell命令">
  <meta property="og:type" content="article">
  <meta property="og:updated_time" content="2022-12-24T08:03:46.000Z">
  <meta property="og:locale" content="zh-CN">
  <meta property="og:locale:alternate" content="en-US">
  <meta property="article:modified_time" content="2022-12-24T08:03:46.000Z">
  <link rel="alternate" hreflang="en-us" href="https://pro.autojs.org/docs/en/zh/v8/shell.html">
  <link rel="icon" href="https://pro.autojs.org/docs/favicon.ico">
  <link rel="manifest" href="https://pro.autojs.org/docs/manifest.webmanifest" crossorigin="use-credentials">
  <meta name="theme-color" content="#46bd87">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
  <title>shell - Shell命令 | Auto.js Pro文档</title>
  <meta name="description" content="支持Node.js的自动化工作流JavaScript IDE">
  <style>
    :root {
      --bg-color: #fff;
    }

    html[data-theme="dark"] {
      --bg-color: #1d2025;
    }

    html,
    body {
      background-color: var(--bg-color);
    }
  </style>
  <script>
    const userMode = localStorage.getItem("vuepress-theme-hope-scheme");
    const systemDarkMode =
      window.matchMedia &&
      window.matchMedia("(prefers-color-scheme: dark)").matches;

    if (userMode === "dark" || (userMode !== "light" && systemDarkMode)) {
      document.querySelector("html").setAttribute("data-theme", "dark");
    }
  </script>
  <link rel="stylesheet" href="../../assets/style.ae9cb182.css">
  <link rel="modulepreload" href="../../assets/app.6aa2b576.js">
  <link rel="modulepreload" href="../../assets/shell.html.39a493bc.js">
  <link rel="modulepreload" href="../../assets/_plugin-vue_export-helper.cdc0426e.js">
  <link rel="modulepreload" href="../../assets/shell.html.65b3fd85.js">
</head>

<body>


  <!-- Copyright � 2008. Spidersoft Ltd -->
  <style>
    A.applink:hover {
      border: 2px dotted #DCE6F4;
      padding: 2px;
      background-color: #ffff00;
      color: green;
      text-decoration: none
    }

    A.applink {
      border: 2px dotted #DCE6F4;
      padding: 2px;
      color: #2F5BFF;
      background: transparent;
      text-decoration: none
    }

    A.info {
      color: #2F5BFF;
      background: transparent;
      text-decoration: none
    }

    A.info:hover {
      color: green;
      background: transparent;
      text-decoration: underline
    }
  </style>


  <div id="app"><!--[--><!--[--><!--[--><span tabindex="-1"></span><a href="#main-content"
      class="skip-link sr-only">Skip to content</a><!--]-->
    <div class="theme-container has-toc"><!--[--><!--[-->
      <header class="navbar">
        <div class="navbar-left"><button class="toggle-sidebar-button" title="Toggle Sidebar"><span
              class="icon"></span></button><!----><a href="../../docs.html" class="brand"><img class="logo"
              src="../../logo.png" alt="Auto.js Pro文档"><!----><span class="site-name hide-in-pad">Auto.js
              Pro文档</span></a><!----></div>
        <div class="navbar-center"><!---->
          <nav class="nav-links">
            <div class="nav-item hide-in-mobile"><a href="../../docs.html" class="nav-link"
                aria-label="Auto.js Pro"><span class="icon iconfont icon-home"></span>Auto.js Pro<!----></a></div>
            <div class="nav-item hide-in-mobile"><a href="../guide/guide.html" class="nav-link" aria-label="指南"><span
                  class="icon iconfont icon-creative"></span>指南<!----></a></div>
            <div class="nav-item hide-in-mobile"><a href="v8.html" class="nav-link active" aria-label="第一代API文档"><span
                  class="icon iconfont icon-note"></span>第一代API文档<!----></a></div>
            <div class="nav-item hide-in-mobile"><a href="../v9/v9.html" class="nav-link" aria-label="第二代API文档"><span
                  class="icon iconfont icon-note"></span>第二代API文档<!----></a></div>
            <div class="nav-item hide-in-mobile">
              <div class="dropdown-wrapper"><button class="dropdown-title" type="button" aria-label="官网与相关链接"><span
                    class="title"><span class="icon iconfont icon-discover"></span>官网与相关链接</span><span
                    class="arrow"></span>
                  <ul class="nav-dropdown">
                    <li class="dropdown-item"><a href="../../../pro.autojs.html" rel="noopener noreferrer"
                        target="_blank" aria-label="官网与软件下载" class="nav-link"><!---->官网与软件下载<span><svg
                            class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"
                            focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15">
                            <path fill="currentColor"
                              d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                            </path>
                            <polygon fill="currentColor"
                              points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                            </polygon>
                          </svg><span class="external-link-icon-sr-only">open in new window</span></span><!----></a>
                    </li>
                    <li class="dropdown-item"><a href="https://blog.autojs.org/" rel="noopener noreferrer"
                        target="_blank" aria-label="官方博客" class="nav-link"><!---->官方博客<span><svg
                            class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"
                            focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15">
                            <path fill="currentColor"
                              d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                            </path>
                            <polygon fill="currentColor"
                              points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                            </polygon>
                          </svg><span class="external-link-icon-sr-only">open in new window</span></span><!----></a>
                    </li>
                    <li class="dropdown-item"><a href="https://pd.qq.com/s/gosos5" rel="noopener noreferrer"
                        target="_blank" aria-label="官方频道" class="nav-link"><!---->官方频道<span><svg
                            class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"
                            focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15">
                            <path fill="currentColor"
                              d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                            </path>
                            <polygon fill="currentColor"
                              points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                            </polygon>
                          </svg><span class="external-link-icon-sr-only">open in new window</span></span><!----></a>
                    </li>
                  </ul>
                </button></div>
            </div>
          </nav><!---->
        </div>
        <div class="navbar-right"><!---->
          <div class="nav-item">
            <div class="dropdown-wrapper i18n-dropdown"><button class="dropdown-title" type="button"
                aria-label="选择语言"><!--[--><svg xmlns="http://www.w3.org/2000/svg" class="icon i18n-icon"
                  viewBox="0 0 1024 1024" fill="currentColor" aria-label="i18n icon"
                  style="width:1rem;height:1rem;vertical-align:middle;">
                  <path
                    d="M379.392 460.8 494.08 575.488l-42.496 102.4L307.2 532.48 138.24 701.44l-71.68-72.704L234.496 460.8l-45.056-45.056c-27.136-27.136-51.2-66.56-66.56-108.544h112.64c7.68 14.336 16.896 27.136 26.112 35.84l45.568 46.08 45.056-45.056C382.976 312.32 409.6 247.808 409.6 204.8H0V102.4h256V0h102.4v102.4h256v102.4H512c0 70.144-37.888 161.28-87.04 210.944L378.88 460.8zM576 870.4 512 1024H409.6l256-614.4H768l256 614.4H921.6l-64-153.6H576zM618.496 768h196.608L716.8 532.48 618.496 768z">
                  </path>
                </svg><!--]--><span class="arrow"></span>
                <ul class="nav-dropdown">
                  <li class="dropdown-item"><a href="../../en/en.html" class="nav-link"
                      aria-label="English"><!---->English<!----></a></li>
                  <li class="dropdown-item"><a aria-current="page" href="shell.html"
                      class="router-link-active router-link-exact-active nav-link active"
                      aria-label="简体中文"><!---->简体中文<!----></a></li>
                </ul>
              </button></div>
          </div><!---->
          <div class="nav-item hide-in-mobile"><button id="appearance-switch"><svg xmlns="http://www.w3.org/2000/svg"
                class="icon auto-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="auto icon"
                style="display:block;">
                <path
                  d="M512 992C246.92 992 32 777.08 32 512S246.92 32 512 32s480 214.92 480 480-214.92 480-480 480zm0-840c-198.78 0-360 161.22-360 360 0 198.84 161.22 360 360 360s360-161.16 360-360c0-198.78-161.22-360-360-360zm0 660V212c165.72 0 300 134.34 300 300 0 165.72-134.28 300-300 300z">
                </path>
              </svg><svg xmlns="http://www.w3.org/2000/svg" class="icon dark-icon" viewBox="0 0 1024 1024"
                fill="currentColor" aria-label="dark icon" style="display:none;">
                <path
                  d="M524.8 938.667h-4.267a439.893 439.893 0 0 1-313.173-134.4 446.293 446.293 0 0 1-11.093-597.334A432.213 432.213 0 0 1 366.933 90.027a42.667 42.667 0 0 1 45.227 9.386 42.667 42.667 0 0 1 10.24 42.667 358.4 358.4 0 0 0 82.773 375.893 361.387 361.387 0 0 0 376.747 82.774 42.667 42.667 0 0 1 54.187 55.04 433.493 433.493 0 0 1-99.84 154.88 438.613 438.613 0 0 1-311.467 128z">
                </path>
              </svg><svg xmlns="http://www.w3.org/2000/svg" class="icon light-icon" viewBox="0 0 1024 1024"
                fill="currentColor" aria-label="light icon" style="display:none;">
                <path
                  d="M952 552h-80a40 40 0 0 1 0-80h80a40 40 0 0 1 0 80zM801.88 280.08a41 41 0 0 1-57.96-57.96l57.96-58a41.04 41.04 0 0 1 58 58l-58 57.96zM512 752a240 240 0 1 1 0-480 240 240 0 0 1 0 480zm0-560a40 40 0 0 1-40-40V72a40 40 0 0 1 80 0v80a40 40 0 0 1-40 40zm-289.88 88.08-58-57.96a41.04 41.04 0 0 1 58-58l57.96 58a41 41 0 0 1-57.96 57.96zM192 512a40 40 0 0 1-40 40H72a40 40 0 0 1 0-80h80a40 40 0 0 1 40 40zm30.12 231.92a41 41 0 0 1 57.96 57.96l-57.96 58a41.04 41.04 0 0 1-58-58l58-57.96zM512 832a40 40 0 0 1 40 40v80a40 40 0 0 1-80 0v-80a40 40 0 0 1 40-40zm289.88-88.08 58 57.96a41.04 41.04 0 0 1-58 58l-57.96-58a41 41 0 0 1 57.96-57.96z">
                </path>
              </svg></button></div>
          <div class="search-box" role="search" data-v-f3875574><input value="" aria-label="Search" class=""
              placeholder="Search" autocomplete="off" spellcheck="false" data-v-f3875574><!----></div><!----><button
            class="toggle-navbar-button" aria-label="Toggle Navbar" aria-expanded="false"
            aria-controls="nav-screen"><span class="button-container"><span class="button-top"></span><span
                class="button-middle"></span><span class="button-bottom"></span></span></button>
        </div>
      </header><!----><!--]--><!---->
      <div class="toggle-sidebar-wrapper"><span class="arrow left"></span></div>
      <aside class="sidebar"><!--[--><!----><!--]-->
        <ul class="sidebar-links">
          <li>
            <section class="sidebar-group">
              <p class="sidebar-heading"><!----><span class="title">指南</span><!----></p>
              <ul class="sidebar-links">
                <li><!--[--><a href="v8.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="阅读须知"><!---->阅读须知<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
              </ul>
            </section>
          </li>
          <li>
            <section class="sidebar-group">
              <p class="sidebar-heading"><!----><span class="title">API文档</span><!----></p>
              <ul class="sidebar-links">
                <li>
                  <section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span
                        class="title">自动化 -
                        控件操作</span><span class="arrow down"></span></button>
                    <ul class="sidebar-links">
                      <li><!--[--><a href="./automator/"
                          class="router-link-active router-link-exact-active nav-link sidebar-link sidebar-page"
                          aria-label="入门介绍" aria-current="page"><!---->入门介绍<!----></a>
                        <ul class="sidebar-sub-headers"></ul><!--]-->
                      </li>
                      <li><!--[--><a href="./automator/selector.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="选择器"><!---->选择器<!----></a>
                        <ul class="sidebar-sub-headers"></ul><!--]-->
                      </li>
                      <li><!--[--><a href="./automator/uiobject.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="控件和控件集合"><!---->控件和控件集合<!----></a>
                        <ul class="sidebar-sub-headers"></ul><!--]-->
                      </li>
                      <li><!--[--><a href="./automator/api.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="automator与其他函数"><!---->automator与其他函数<!----></a>
                        <ul class="sidebar-sub-headers"></ul><!--]-->
                      </li>
                    </ul>
                  </section>
                </li>
                <li><!--[--><a href="./coordinatesBasedAutomation.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="自动化 - 坐标操作"><!---->自动化 -
                    坐标操作<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./app.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="app - 应用"><!---->app -
                    应用<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./base64.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="base64"><!---->base64<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./colors.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="colors - 颜色"><!---->colors - 颜色<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./canvas.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="canvas - 画布"><!---->canvas - 画布<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./console.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="console - 控制台"><!---->console - 控制台<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./crypto.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="crypto - 加解密与消息摘要"><!---->crypto - 加解密与消息摘要<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./debug.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="debug - 调试工具"><!---->debug - 调试工具<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./device.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="device - 设备"><!---->device - 设备<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./dialogs.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="dialogs - 对话框"><!---->dialogs - 对话框<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./engines.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="engines - 脚本引擎"><!---->engines - 脚本引擎<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./events.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="events - 事件与监听"><!---->events - 事件与监听<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./floaty.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="floaty - 悬浮窗"><!---->floaty - 悬浮窗<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./files.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="files - 文件系统"><!---->files - 文件系统<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./globals.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="globals - 全局变量与函数"><!---->globals - 全局变量与函数<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./http.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="http - HTTP网络请求"><!---->http - HTTP网络请求<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./images.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="images - 图片处理"><!---->images - 图片处理<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./keys.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="keys - 按键模拟"><!---->keys
                    - 按键模拟<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./media.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="media - 多媒体"><!---->media
                    - 多媒体<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./modules.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="module - 模块"><!---->module - 模块<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./ocr.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="ocr - 文字识别"><!---->ocr -
                    文字识别<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./plugins.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="plugins - 插件"><!---->plugins - 插件<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./powerManager.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="power_manager - 电源管理"><!---->power_manager - 电源管理<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./sensors.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="sensors - 传感器"><!---->sensors - 传感器<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./shell.html" class="nav-link sidebar-link sidebar-page active"
                    aria-label="shell - Shell命令"><!---->shell - Shell命令<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./storages.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="storages - 本地存储"><!---->storages - 本地存储<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./settings.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="settings - 设置"><!---->settings - 设置<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./threads.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="threads - 多线程"><!---->threads - 多线程<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./timers.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="timers - 定时器"><!---->timers - 定时器<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./timedTasks.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="work_manager - 定时与任务"><!---->work_manager - 定时与任务<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li>
                  <section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span
                        class="title">ui - 用户界面</span><span class="arrow down"></span></button>
                    <ul class="sidebar-links">
                      <li><a href="/docs/zh/v8/ui/ui.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="ui入门介绍"><!---->ui入门介绍<!----></a>
                        <ul class="sidebar-sub-headers"></ul>
                      </li>
                      <li><a href="/docs/zh/v8/ui/basic.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="基础布局与控件"><!---->基础布局与控件<!----></a>
                        <ul class="sidebar-sub-headers"></ul>
                      </li>
                      <li><a href="/docs/zh/v8/ui/advanced.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="其他布局与控件"><!---->其他布局与控件<!----></a>
                        <ul class="sidebar-sub-headers"></ul>
                      </li>
                      <li><a href="/docs/zh/v8/ui/api.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="api文档"><!---->api文档<!----></a>
                        <ul class="sidebar-sub-headers"></ul>
                      </li>
                      <li><a href="/docs/zh/v8/ui/customWidget.html" class="nav-link sidebar-link sidebar-page"
                          aria-label="自定义控件"><!---->自定义控件<!----></a>
                        <ul class="sidebar-sub-headers"></ul>
                      </li>
                      <li><a aria-current="page" href="/docs/zh/v8/ui/webview.html"
                          class="router-link-active router-link-exact-active nav-link sidebar-link sidebar-page"
                          aria-label="使用Web编写界面"><!---->使用Web编写界面<!----></a>
                        <ul class="sidebar-sub-headers"></ul>
                      </li>
                    </ul>
                  </section>
                </li>
                <li><!--[--><a href="./util.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="util - 工具"><!---->util -
                    工具<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./webSocket.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="WebSocket"><!---->WebSocket<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="./zip.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="zip - 压缩与解压"><!---->zip -
                    压缩与解压<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
              </ul>
            </section>
          </li>
          <li>
            <section class="sidebar-group">
              <p class="sidebar-heading"><!----><span class="title">进阶</span><!----></p>
              <ul class="sidebar-links">
                <li><!--[--><a href="scriptingJava.html" class="nav-link sidebar-link sidebar-page"
                    aria-label="和Java交互"><!---->和Java交互<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
              </ul>
            </section>
          </li>
        </ul><!--[--><!----><!--]-->
      </aside><!--[-->
      <main class="page" id="main-content"><!--[--><!---->
        <nav class="breadcrumb disable"></nav>
        <div class="page-title">
          <h1><!---->shell - Shell命令</h1>
          <div class="page-info"><span class="date-info" aria-label="写作日期📅" data-balloon-pos="down"><svg
                xmlns="http://www.w3.org/2000/svg" class="icon calendar-icon" viewBox="0 0 1024 1024"
                fill="currentColor" aria-label="calendar icon">
                <path
                  d="M716.4 110.137c0-18.753-14.72-33.473-33.472-33.473-18.753 0-33.473 14.72-33.473 33.473v33.473h66.993v-33.473zm-334.87 0c0-18.753-14.72-33.473-33.473-33.473s-33.52 14.72-33.52 33.473v33.473h66.993v-33.473zm468.81 33.52H716.4v100.465c0 18.753-14.72 33.473-33.472 33.473a33.145 33.145 0 01-33.473-33.473V143.657H381.53v100.465c0 18.753-14.72 33.473-33.473 33.473a33.145 33.145 0 01-33.473-33.473V143.657H180.6A134.314 134.314 0 0046.66 277.595v535.756A134.314 134.314 0 00180.6 947.289h669.74a134.36 134.36 0 00133.94-133.938V277.595a134.314 134.314 0 00-133.94-133.938zm33.473 267.877H147.126a33.145 33.145 0 01-33.473-33.473c0-18.752 14.72-33.473 33.473-33.473h736.687c18.752 0 33.472 14.72 33.472 33.473a33.145 33.145 0 01-33.472 33.473z">
                </path>
              </svg><span>2022年10月22日</span>
              <meta property="datePublished" content="2022-10-22T07:36:15.000Z">
            </span></div>
          <hr>
        </div>
        <div class="toc-place-holder">
          <aside id="toc">
            <div class="toc-header">此页内容</div>
            <div class="toc-wrapper">
              <ul class="toc-list"><!--[-->
                <li class="toc-item"><a aria-current="page"
                    href="https://pro.autojs.org/docs/zh/v8/shell.html#shell-cmd-root"
                    class="router-link-active router-link-exact-active toc-link level2">shell(cmd[, root])</a></li>
                <!----><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page"
                    href="https://pro.autojs.org/docs/zh/v8/shell.html#new-shell-root"
                    class="router-link-active router-link-exact-active toc-link level2">new Shell(root)</a></li>
                <!----><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page"
                    href="https://pro.autojs.org/docs/zh/v8/shell.html#shell-exec-cmd"
                    class="router-link-active router-link-exact-active toc-link level2">Shell.exec(cmd)</a></li>
                <!----><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page"
                    href="https://pro.autojs.org/docs/zh/v8/shell.html#shell-exit"
                    class="router-link-active router-link-exact-active toc-link level2">Shell.exit()</a></li>
                <!----><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page"
                    href="https://pro.autojs.org/docs/zh/v8/shell.html#shell-exitandwaitfor"
                    class="router-link-active router-link-exact-active toc-link level2">Shell.exitAndWaitFor()</a></li>
                <!----><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page"
                    href="https://pro.autojs.org/docs/zh/v8/shell.html#shell-setcallback-callback"
                    class="router-link-active router-link-exact-active toc-link level2">Shell.setCallback(callback)</a>
                </li><!----><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page" href="https://pro.autojs.org/docs/zh/v8/shell.html#am命令"
                    class="router-link-active router-link-exact-active toc-link level2">am命令</a></li>
                <ul class="toc-list"><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#start-options-intent"
                      class="router-link-active router-link-exact-active toc-link level3">start [options] intent</a>
                  </li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#startservice-options-intent"
                      class="router-link-active router-link-exact-active toc-link level3">startservice [options]
                      intent</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#force-stop-package"
                      class="router-link-active router-link-exact-active toc-link level3">force-stop package</a></li>
                  <!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#kill-options-package"
                      class="router-link-active router-link-exact-active toc-link level3">kill [options] package</a>
                  </li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#kill-all"
                      class="router-link-active router-link-exact-active toc-link level3">kill-all</a></li>
                  <!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#broadcast-options-intent"
                      class="router-link-active router-link-exact-active toc-link level3">broadcast [options] intent</a>
                  </li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#instrument-options-component"
                      class="router-link-active router-link-exact-active toc-link level3">instrument [options]
                      component</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#dumpheap-options-process-file"
                      class="router-link-active router-link-exact-active toc-link level3">dumpheap [options] process
                      file</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#monitor-options-启动对崩溃或-anr-的监控�?"
                      class="router-link-active router-link-exact-active toc-link level3">monitor [options] 启动对崩溃或 ANR
                      的监控。</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#screen-compat-on-off-package"
                      class="router-link-active router-link-exact-active toc-link level3">screen-compat {on|off}
                      package</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#display-size-reset-widthxheight"
                      class="router-link-active router-link-exact-active toc-link level3">display-size
                      [reset|widthxheight]</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#display-density-dpi"
                      class="router-link-active router-link-exact-active toc-link level3">display-density dpi</a></li>
                  <!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#to-uri-intent"
                      class="router-link-active router-link-exact-active toc-link level3">to-uri intent</a></li>
                  <!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#to-intent-uri-intent"
                      class="router-link-active router-link-exact-active toc-link level3">to-intent-uri intent</a></li>
                  <!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#intent参数的规�?"
                      class="router-link-active router-link-exact-active toc-link level3">intent参数的规范</a></li>
                  <!----><!--]-->
                </ul><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page" href="https://pro.autojs.org/docs/zh/v8/shell.html#应用包名"
                    class="router-link-active router-link-exact-active toc-link level2">应用包名</a></li>
                <!----><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page" href="https://pro.autojs.org/docs/zh/v8/shell.html#pm命令"
                    class="router-link-active router-link-exact-active toc-link level2">pm命令</a></li>
                <ul class="toc-list"><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#list-packages-options-filter"
                      class="router-link-active router-link-exact-active toc-link level3">list packages [options]
                      filter</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#list-permission-groups"
                      class="router-link-active router-link-exact-active toc-link level3">list permission-groups</a>
                  </li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#list-permissions-options-group"
                      class="router-link-active router-link-exact-active toc-link level3">list permissions [options]
                      group</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#list-instrumentation-options"
                      class="router-link-active router-link-exact-active toc-link level3">list instrumentation
                      [options]</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#list-features"
                      class="router-link-active router-link-exact-active toc-link level3">list features</a></li>
                  <!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#list-libraries"
                      class="router-link-active router-link-exact-active toc-link level3">list libraries</a></li>
                  <!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#list-users"
                      class="router-link-active router-link-exact-active toc-link level3">list users</a></li>
                  <!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#path-package"
                      class="router-link-active router-link-exact-active toc-link level3">path package</a></li>
                  <!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#install-options-path"
                      class="router-link-active router-link-exact-active toc-link level3">install [options] path</a>
                  </li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#uninstall-options-package"
                      class="router-link-active router-link-exact-active toc-link level3">uninstall [options]
                      package</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#clear-package"
                      class="router-link-active router-link-exact-active toc-link level3">clear package</a></li>
                  <!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#enable-package-or-component"
                      class="router-link-active router-link-exact-active toc-link level3">enable
                      package_or_component</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#disable-package-or-component"
                      class="router-link-active router-link-exact-active toc-link level3">disable
                      package_or_component</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#disable-user-options-package-or-component"
                      class="router-link-active router-link-exact-active toc-link level3">disable-user [options]
                      package_or_component</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#grant-package-name-permission"
                      class="router-link-active router-link-exact-active toc-link level3">grant package_name
                      permission</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#revoke-package-name-permission"
                      class="router-link-active router-link-exact-active toc-link level3">revoke package_name
                      permission</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#set-install-location-location"
                      class="router-link-active router-link-exact-active toc-link level3">set-install-location
                      location</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#get-install-location"
                      class="router-link-active router-link-exact-active toc-link level3">get-install-location</a></li>
                  <!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#set-permission-enforced-permission-true-false"
                      class="router-link-active router-link-exact-active toc-link level3">set-permission-enforced
                      permission [true|false]</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#trim-caches-desired-free-space"
                      class="router-link-active router-link-exact-active toc-link level3">trim-caches
                      desired_free_space</a></li><!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#create-user-user-name"
                      class="router-link-active router-link-exact-active toc-link level3">create-user user_name</a></li>
                  <!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#remove-user-user-id"
                      class="router-link-active router-link-exact-active toc-link level3">remove-user user_id</a></li>
                  <!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page"
                      href="https://pro.autojs.org/docs/zh/v8/shell.html#get-max-users"
                      class="router-link-active router-link-exact-active toc-link level3">get-max-users</a></li>
                  <!----><!--]-->
                </ul><!--]--><!--[-->
                <li class="toc-item"><a aria-current="page" href="https://pro.autojs.org/docs/zh/v8/shell.html#其他命令"
                    class="router-link-active router-link-exact-active toc-link level2">其他命令</a></li>
                <ul class="toc-list"><!--[-->
                  <li class="toc-item"><a aria-current="page" href="https://pro.autojs.org/docs/zh/v8/shell.html#进行屏幕截图"
                      class="router-link-active router-link-exact-active toc-link level3">进行屏幕截图</a></li>
                  <!----><!--]--><!--[-->
                  <li class="toc-item"><a aria-current="page" href="https://pro.autojs.org/docs/zh/v8/shell.html#列表文件"
                      class="router-link-active router-link-exact-active toc-link level3">列表文件</a></li><!----><!--]-->
                </ul><!--]-->
              </ul>
            </div>
          </aside>
        </div><!---->
        <div class="theme-hope-content">
          <h1 id="shell-shell命令" tabindex="-1"><a class="header-anchor" href="#shell-shell命令" aria-hidden="true">#</a>
            shell - Shell命令</h1>
          <p>shell即Unix Shell，在类Unix系统提供与操作系统交互的一系列命令。</p>
          <p>很多程序可以用来执行shell命令，例如终端模拟器。</p>
          <p>在Auto.js大致等同于用adb执行命令&quot;adb shell&quot;。其实现包括两种方式：</p>
          <ul>
            <li>
              通过<code>java<span class="token punctuation">.</span>lang<span class="token punctuation">.</span>Runtime<span class="token punctuation">.</span>exec</code>执行(shell,
              Tap, Home等函数)</li>
            <li>通过内嵌终端模拟器执行(RootAutomator, Shell等对象)</li>
          </ul>
          <blockquote>
            <p>Stability: 2 - Stable</p>
          </blockquote>
          <h2 id="shell-cmd-root" tabindex="-1"><a class="header-anchor" href="#shell-cmd-root" aria-hidden="true">#</a>
            shell(cmd[, root])</h2>
          <ul>
            <li><code><span class="token property">cmd</span></code> {string} 要执行的命令</li>
            <li><code><span class="token property">root</span></code> {Boolean} 是否以root权限运行，默认为false。</li>
          </ul>
          <p>一次性执行命令cmd, 并返回命令的执行结果。返回对象的其属性如下:</p>
          <ul>
            <li><code><span class="token property">code</span></code> {number} 返回码。执行成功时为0，失败时为非0的数字。</li>
            <li><code><span class="token property">result</span></code> {string} 运行结果(stdout输出结果)</li>
            <li><code><span class="token property">error</span></code> {string}
              运行的错误信息(stderr输出结果)。例如执行需要root权限的命令但没有授予root权限会返回错误信息&quot;Permission denied&quot;。</li>
          </ul>
          <p>示例(强制停止微信) ：</p>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code><span class="token keyword">var</span> result <span class="token operator">=</span> <span class="token function">shell</span><span class="token punctuation">(</span><span class="token string">&quot;am force-stop com.tencent.mm&quot;</span><span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">log</span><span class="token punctuation">(</span>result<span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">show</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>result<span class="token punctuation">.</span>code <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token function">toast</span><span class="token punctuation">(</span><span class="token string">&quot;执行成功&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
<span class="token function">toast</span><span class="token punctuation">(</span><span class="token string">&quot;执行失败！请到控制台查看错误信息&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
            </div>
          </div>
          <h1 id="shell" tabindex="-1"><a class="header-anchor" href="#shell" aria-hidden="true">#</a> Shell</h1>
          <blockquote>
            <p>Stability: 2 - Stable</p>
          </blockquote>
          <p>
            shell函数通过用来一次性执行单条命令并获取结果。如果有多条命令需要执行，用Shell对象的效率更高。这是因为，每次运行shell函数都会打开一个单独的shell进程并在运行结束后关闭他，这个过程需要一定的时间；而Shell对象自始至终使用同一个shell进程。
          </p>
          <h2 id="new-shell-root" tabindex="-1"><a class="header-anchor" href="#new-shell-root" aria-hidden="true">#</a>
            new Shell(root)</h2>
          <ul>
            <li><code><span class="token property">root</span></code> {Boolean}
              是否以root权限运行一个shell进程，默认为false。这将会影响其后使用该Shell对象执行的命令的权限</li>
          </ul>
          <p>Shell对象的&quot;构造函数&quot;。</p>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code><span class="token keyword">var</span> sh <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Shell</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//强制停止微信</span>
sh<span class="token punctuation">.</span><span class="token function">exec</span><span class="token punctuation">(</span><span class="token string">&quot;am force-stop com.tencent.mm&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
sh<span class="token punctuation">.</span><span class="token function">exit</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
            </div>
          </div>
          <h2 id="shell-exec-cmd" tabindex="-1"><a class="header-anchor" href="#shell-exec-cmd" aria-hidden="true">#</a>
            Shell.exec(cmd)</h2>
          <ul>
            <li><code><span class="token property">cmd</span></code> {string} 要执行的命令</li>
          </ul>
          <p>执行命令cmd。该函数不会返回任何值。</p>
          <p>注意，命令执行是&quot;异步&quot;的、非阻塞的。也就是不会等待命令完成后才继续向下执行。</p>
          <p>
            尽管这样的设计使用起来有很多不便之处，但受限于终端模拟器，暂时没有解决方式；如果后续能找到解决方案，则将提供<code>Shell<span class="token punctuation">.</span>execAndWaitFor</code>函数。
          </p>
          <h2 id="shell-exit" tabindex="-1"><a class="header-anchor" href="#shell-exit" aria-hidden="true">#</a>
            Shell.exit()</h2>
          <p>直接退出shell。正在执行的命令会被强制退出。</p>
          <h2 id="shell-exitandwaitfor" tabindex="-1"><a class="header-anchor" href="#shell-exitandwaitfor"
              aria-hidden="true">#</a> Shell.exitAndWaitFor()</h2>
          <p>执行&quot;exit&quot;命令并等待执行命令执行完成、退出shell。</p>
          <p>此函数会执行exit命令来正常退出shell。</p>
          <h2 id="shell-setcallback-callback" tabindex="-1"><a class="header-anchor" href="#shell-setcallback-callback"
              aria-hidden="true">#</a> Shell.setCallback(callback)</h2>
          <ul>
            <li><code><span class="token property">callback</span></code> {Object} 回调函数</li>
          </ul>
          <p>设置该Shell的回调函数，以便监听Shell的输出。可以包括以下属性：</p>
          <ul>
            <li>onOutput {Function} 每当shell有新的输出时便会调用该函数。其参数是一个字符串。</li>
            <li>onNewLine {Function} 每当shell有新的一行输出时便会调用该函数。其参数是一个字符串(不包括最后的换行符)。</li>
          </ul>
          <p>例如:</p>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code><span class="token keyword">var</span> sh <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Shell</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
sh<span class="token punctuation">.</span><span class="token function">setCallback</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
<span class="token function-variable function">onNewLine</span><span class="token operator">:</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token parameter">line</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
	<span class="token comment">//有新的一行输出时打印到控制台</span>
	<span class="token function">log</span><span class="token punctuation">(</span>line<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token keyword">while</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token comment">//循环输入命令</span>
<span class="token keyword">var</span> cmd <span class="token operator">=</span> dialogs<span class="token punctuation">.</span><span class="token function">rawInput</span><span class="token punctuation">(</span><span class="token string">&quot;请输入要执行的命令，输入exit退出&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>cmd <span class="token operator">==</span> <span class="token string">&quot;exit&quot;</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
	<span class="token keyword">break</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token comment">//执行命令</span>
sh<span class="token punctuation">.</span><span class="token function">exec</span><span class="token punctuation">(</span>cmd<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
sh<span class="token punctuation">.</span><span class="token function">exit</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
            </div>
          </div>
          <h1 id="附录-shell命令简介" tabindex="-1"><a class="header-anchor" href="#附录-shell命令简介" aria-hidden="true">#</a> 附录:
            shell命令简介</h1>
          <p>以下关于shell命令的资料来自<a href="https://developer.android.com/studio/command-line/adb.html#shellcommands"
              target="_blank" rel="noopener noreferrer">AndroidStudio用户指南：Shell命令<span><svg class="external-link-icon"
                  xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px"
                  viewBox="0 0 100 100" width="15" height="15">
                  <path fill="currentColor"
                    d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                  </path>
                  <polygon fill="currentColor"
                    points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                  </polygon>
                </svg><span class="external-link-icon-sr-only">open in new window</span></span></a>。</p>
          <h2 id="am命令" tabindex="-1"><a class="header-anchor" href="#am命令" aria-hidden="true">#</a> am命令</h2>
          <p>am命令即Activity Manager命令，用于管理应用程序活动、服务等。</p>
          <p><strong>以下命令均以&quot;am
              &quot;开头，例如<code><span class="token function">shell</span><span class="token punctuation">(</span><span class="token string">&#39;am start -p com.tencent.mm&#39;</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code>(启动微信)</strong>
          </p>
          <h3 id="start-options-intent" tabindex="-1"><a class="header-anchor" href="#start-options-intent"
              aria-hidden="true">#</a> start [options] intent</h3>
          <p>启动 intent 指定的 Activity(应用程序活动)。<br> 请参阅 <a href="#shell_intent">intent 参数的规范</a>。</p>
          <p>选项包括：</p>
          <ul>
            <li>-D：启用调试。</li>
            <li>-W：等待启动完成。</li>
            <li>--start-profiler file：启动分析器并将结果发送到 file。</li>
            <li>-P file：类似于 --start-profiler，但当应用进入空闲状态时分析停止。</li>
            <li>-R count：重复 Activity 启动 count 次数。在每次重复前，将完成顶部 Activity。</li>
            <li>-S：启动 Activity 前强行停止目标应用。</li>
            <li>--opengl-trace：启用 OpenGL 函数的跟踪。</li>
            <li>--user user_id | current：指定要作为哪个用户运行；如果未指定，则作为当前用户运行。</li>
          </ul>
          <h3 id="startservice-options-intent" tabindex="-1"><a class="header-anchor"
              href="#startservice-options-intent" aria-hidden="true">#</a> startservice [options] intent</h3>
          <p>启动 intent 指定的 Service(服务)。<br> 请参阅 <a href="#shell_intent">intent 参数的规范</a>。<br> 选项包括：</p>
          <ul>
            <li>--user user_id | current：指定要作为哪个用户运行；如果未指定，则作为当前用户运行。</li>
          </ul>
          <h3 id="force-stop-package" tabindex="-1"><a class="header-anchor" href="#force-stop-package"
              aria-hidden="true">#</a> force-stop package</h3>
          <p>强行停止与 package（<a href="#%E5%BA%94%E7%94%A8%E5%8C%85%E5%90%8D">应用包名</a>）关联的所有应用。</p>
          <h3 id="kill-options-package" tabindex="-1"><a class="header-anchor" href="#kill-options-package"
              aria-hidden="true">#</a> kill [options] package</h3>
          <p>终止与 package（<a href="#%E5%BA%94%E7%94%A8%E5%8C%85%E5%90%8D">应用包名</a>）关联的所有进程。此命令仅终止可安全终止且不会影响用户体验的进程。<br>
            选项包括：</p>
          <ul>
            <li>--user user_id | all | current：指定将终止其进程的用户；如果未指定，则终止所有用户的进程。</li>
          </ul>
          <h3 id="kill-all" tabindex="-1"><a class="header-anchor" href="#kill-all" aria-hidden="true">#</a> kill-all
          </h3>
          <p>终止所有后台进程。</p>
          <h3 id="broadcast-options-intent" tabindex="-1"><a class="header-anchor" href="#broadcast-options-intent"
              aria-hidden="true">#</a> broadcast [options] intent</h3>
          <p>发出广播 intent。 请参阅 <a href="#shell_intent">intent 参数的规范</a>。</p>
          <p>选项包括：</p>
          <ul>
            <li>[--user user_id | all | current]：指定要发送到的用户；如果未指定，则发送到所有用户。</li>
          </ul>
          <h3 id="instrument-options-component" tabindex="-1"><a class="header-anchor"
              href="#instrument-options-component" aria-hidden="true">#</a> instrument [options] component</h3>
          <p>使用 Instrumentation 实例启动监控。通常，目标 component 是表单 test_package/runner_class。<br> 选项包括：</p>
          <ul>
            <li>-r：输出原始结果（否则对 report_key_streamresult 进行解码）。与 [-e perf true] 结合使用以生成性能测量的原始输出。</li>
            <li>-e name value：将参数 name 设为 value。对于测试运行器，通用表单为 -e testrunner_flag value[,value...]。</li>
            <li>-p file：将分析数据写入 file。</li>
            <li>-w：先等待仪器完成，然后再返回。测试运行器需要使用此选项。</li>
            <li>--no-window-animation：运行时关闭窗口动画。</li>
            <li>--user user_id | current：指定仪器在哪个用户中运行；如果未指定，则在当前用户中运行。</li>
            <li>profile start process file 启动 process 的分析器，将结果写入 file。</li>
            <li>profile stop process 停止 process 的分析器。</li>
          </ul>
          <h3 id="dumpheap-options-process-file" tabindex="-1"><a class="header-anchor"
              href="#dumpheap-options-process-file" aria-hidden="true">#</a> dumpheap [options] process file</h3>
          <p>转储 process 的堆，写入 file。</p>
          <p>选项包括：</p>
          <ul>
            <li>--user [user_id|current]：提供进程名称时，指定要转储的进程用户；如果未指定，则使用当前用户。</li>
            <li>-n：转储原生堆，而非托管堆。</li>
            <li>set-debug-app [options] package 将应用 package 设为调试。</li>
          </ul>
          <p>选项包括：</p>
          <ul>
            <li>-w：应用启动时等待调试程序。</li>
            <li>--persistent：保留此值。</li>
            <li>clear-debug-app 使用 set-debug-app 清除以前针对调试用途设置的软件包。</li>
          </ul>
          <h3 id="monitor-options-启动对崩溃或-anr-的监控。" tabindex="-1"><a class="header-anchor"
              href="#monitor-options-启动对崩溃或-anr-的监控。" aria-hidden="true">#</a> monitor [options] 启动对崩溃或 ANR 的监控。</h3>
          <p>选项包括：</p>
          <ul>
            <li>--gdb：在崩溃/ANR 时在给定端口上启动 gdbserv。</li>
          </ul>
          <h3 id="screen-compat-on-off-package" tabindex="-1"><a class="header-anchor"
              href="#screen-compat-on-off-package" aria-hidden="true">#</a> screen-compat {on|off} package</h3>
          <p>控制 package 的屏幕兼容性模式。</p>
          <h3 id="display-size-reset-widthxheight" tabindex="-1"><a class="header-anchor"
              href="#display-size-reset-widthxheight" aria-hidden="true">#</a> display-size [reset|widthxheight]</h3>
          <p>替换模拟器/设备显示尺寸。此命令对于在不同尺寸的屏幕上测试您的应用非常有用，它支持使用大屏设备模仿小屏幕分辨率（反之亦然）。<br> 示例：</p>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code><span class="token function">shell</span><span class="token punctuation">(</span><span class="token string">&quot;am display-size 1280x800&quot;</span><span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
              <div class="line-number"></div>
            </div>
          </div>
          <h3 id="display-density-dpi" tabindex="-1"><a class="header-anchor" href="#display-density-dpi"
              aria-hidden="true">#</a> display-density dpi</h3>
          <p>替换模拟器/设备显示密度。此命令对于在不同密度的屏幕上测试您的应用非常有用，它支持使用低密度屏幕在高密度环境环境上进行测试（反之亦然）。<br> 示例：</p>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code><span class="token function">shell</span><span class="token punctuation">(</span><span class="token string">&quot;am display-density 480&quot;</span><span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
            </div>
          </div>
          <h3 id="to-uri-intent" tabindex="-1"><a class="header-anchor" href="#to-uri-intent" aria-hidden="true">#</a>
            to-uri intent</h3>
          <p>将给定的 intent 规范以 URI 的形式输出。 请参阅 <a href="#shell_intent">intent 参数的规范</a>。</p>
          <h3 id="to-intent-uri-intent" tabindex="-1"><a class="header-anchor" href="#to-intent-uri-intent"
              aria-hidden="true">#</a> to-intent-uri intent</h3>
          <p>将给定的 intent 规范以 intent:URI 的形式输出。 请参阅 intent 参数的规范。</p>
          <h3 id="intent参数的规范" tabindex="-1"><a class="header-anchor" href="#intent参数的规范" aria-hidden="true">#</a>
            intent参数的规范</h3>
          <p>对于采用 intent 参数的 am 命令，您可以使用以下选项指定 intent：</p>
          <ul>
            <li>-a action<br> 指定 intent 操作，如“android.intent.action.VIEW”。此指定只能声明一次。</li>
            <li>-d data_uri<br> 指定 intent 数据 URI，如“content://contacts/people/1”。此指定只能声明一次。</li>
            <li>-t mime_type<br> 指定 intent MIME 类型，如“image/png”。此指定只能声明一次。</li>
            <li>-c category<br> 指定 intent 类别，如“android.intent.category.APP_CONTACTS”。</li>
            <li>-n component<br> 指定带有软件包名称前缀的组件名称以创建显式 intent，如“com.example.app/.ExampleActivity”。</li>
            <li>-f flags<br> 将标志添加到 setFlags() 支持的 intent。</li>
            <li>--esn extra_key<br> 添加一个 null extra。URI intent 不支持此选项。</li>
            <li>-e|--es extra_key extra_string_value<br> 添加字符串数据作为键值对。</li>
            <li>--ez extra_key extra_boolean_value<br> 添加布尔型数据作为键值对。</li>
            <li>--ei extra_key extra_int_value<br> 添加整数型数据作为键值对。</li>
            <li>--el extra_key extra_long_value<br> 添加长整型数据作为键值对。</li>
            <li>--ef extra_key extra_float_value<br> 添加浮点型数据作为键值对。</li>
            <li>--eu extra_key extra_uri_value<br> 添加 URI 数据作为键值对。</li>
            <li>--ecn extra_key extra_component_name_value<br> 添加组件名称，将其作为 ComponentName 对象进行转换和传递。</li>
            <li>--eia extra_key extra_int_value[,extra_int_value...]<br> 添加整数数组。</li>
            <li>--ela extra_key extra_long_value[,extra_long_value...]<br> 添加长整型数组。</li>
            <li>--efa extra_key extra_float_value[,extra_float_value...]<br> 添加浮点型数组。</li>
            <li>--grant-read-uri-permission<br> 包含标志 FLAG_GRANT_READ_URI_PERMISSION。</li>
            <li>--grant-write-uri-permission<br> 包含标志 FLAG_GRANT_WRITE_URI_PERMISSION。</li>
            <li>--debug-log-resolution<br> 包含标志 FLAG_DEBUG_LOG_RESOLUTION。</li>
            <li>--exclude-stopped-packages<br> 包含标志 FLAG_EXCLUDE_STOPPED_PACKAGES。</li>
            <li>--include-stopped-packages<br> 包含标志 FLAG_INCLUDE_STOPPED_PACKAGES。</li>
            <li>--activity-brought-to-front<br> 包含标志 FLAG_ACTIVITY_BROUGHT_TO_FRONT。</li>
            <li>--activity-clear-top<br> 包含标志 FLAG_ACTIVITY_CLEAR_TOP。</li>
            <li>--activity-clear-when-task-reset<br> 包含标志 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET。</li>
            <li>--activity-exclude-from-recents<br> 包含标志 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS。</li>
            <li>--activity-launched-from-history<br> 包含标志 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY。</li>
            <li>--activity-multiple-task<br> 包含标志 FLAG_ACTIVITY_MULTIPLE_TASK。</li>
            <li>--activity-no-animation<br> 包含标志 FLAG_ACTIVITY_NO_ANIMATION。</li>
            <li>--activity-no-history<br> 包含标志 FLAG_ACTIVITY_NO_HISTORY。</li>
            <li>--activity-no-user-action<br> 包含标志 FLAG_ACTIVITY_NO_USER_ACTION。</li>
            <li>--activity-previous-is-top<br> 包含标志 FLAG_ACTIVITY_PREVIOUS_IS_TOP。</li>
            <li>--activity-reorder-to-front<br> 包含标志 FLAG_ACTIVITY_REORDER_TO_FRONT。</li>
            <li>--activity-reset-task-if-needed<br> 包含标志 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED。</li>
            <li>--activity-single-top<br> 包含标志 FLAG_ACTIVITY_SINGLE_TOP。</li>
            <li>--activity-clear-task<br> 包含标志 FLAG_ACTIVITY_CLEAR_TASK。</li>
            <li>--activity-task-on-home<br> 包含标志 FLAG_ACTIVITY_TASK_ON_HOME。</li>
            <li>--receiver-registered-only<br> 包含标志 FLAG_RECEIVER_REGISTERED_ONLY。</li>
            <li>--receiver-replace-pending<br> 包含标志 FLAG_RECEIVER_REPLACE_PENDING。</li>
            <li>--selector<br> 需要使用 -d 和 -t 选项以设置 intent 数据和类型。</li>
          </ul>
          <h4 id="uri-component-package" tabindex="-1"><a class="header-anchor" href="#uri-component-package"
              aria-hidden="true">#</a> URI component package</h4>
          <p>如果不受上述某一选项的限制，您可以直接指定 URI、软件包名称和组件名称。当参数不受限制时，如果参数包含一个“:”（冒号），则此工具假定参数是一个
            URI；如果参数包含一个“/”（正斜杠），则此工具假定参数是一个组件名称；否则，此工具假定参数是一个软件包名称。</p>
          <h2 id="应用包名" tabindex="-1"><a class="header-anchor" href="#应用包名" aria-hidden="true">#</a> 应用包名</h2>
          <p>所谓应用包名，是唯一确定应用的标识。例如微信的包名是&quot;com.tencent.mm&quot;, QQ的包名是&quot;com.tencent.mobileqq&quot;。<br>
            要获取一个应用的包名，可以通过函数<code><span class="token function">getPackageName</span><span class="token punctuation">(</span>appName<span class="token punctuation">)</span></code>获取。参见帮助-&gt;其他一般函数。
          </p>
          <h2 id="pm命令" tabindex="-1"><a class="header-anchor" href="#pm命令" aria-hidden="true">#</a> pm命令</h2>
          <p>pm命令用于管理应用程序，例如卸载应用、冻结应用等。<br><strong>以下命令均以&quot;pm &quot;开头，例如&quot;shell(&quot;pm disable
              com.tencent.mm&quot;);&quot;(冻结微信)</strong></p>
          <h3 id="list-packages-options-filter" tabindex="-1"><a class="header-anchor"
              href="#list-packages-options-filter" aria-hidden="true">#</a> list packages [options] filter</h3>
          <p>输出所有软件包，或者，仅输出包名称包含 filter 中的文本的软件包。<br> 选项：</p>
          <ul>
            <li>-f：查看它们的关联文件。</li>
            <li>-d：进行过滤以仅显示已停用的软件包。</li>
            <li>-e：进行过滤以仅显示已启用的软件包。</li>
            <li>-s：进行过滤以仅显示系统软件包。</li>
            <li>-3：进行过滤以仅显示第三方软件包。</li>
            <li>-i：查看软件包的安装程序。</li>
            <li>-u：也包括卸载的软件包。</li>
            <li>--user user_id：要查询的用户空间。</li>
          </ul>
          <h3 id="list-permission-groups" tabindex="-1"><a class="header-anchor" href="#list-permission-groups"
              aria-hidden="true">#</a> list permission-groups</h3>
          <p>输出所有已知的权限组。</p>
          <h3 id="list-permissions-options-group" tabindex="-1"><a class="header-anchor"
              href="#list-permissions-options-group" aria-hidden="true">#</a> list permissions [options] group</h3>
          <p>输出所有已知权限，或者，仅输出 group 中的权限。<br> 选项：</p>
          <ul>
            <li>-g：按组加以组织。</li>
            <li>-f：输出所有信息。</li>
            <li>-s：简短摘要。</li>
            <li>-d：仅列出危险权限。</li>
            <li>-u：仅列出用户将看到的权限。</li>
          </ul>
          <h3 id="list-instrumentation-options" tabindex="-1"><a class="header-anchor"
              href="#list-instrumentation-options" aria-hidden="true">#</a> list instrumentation [options]</h3>
          <p>列出所有测试软件包。<br> 选项：</p>
          <ul>
            <li>-f：列出用于测试软件包的 APK 文件。</li>
            <li>target_package：列出仅用于此应用的测试软件包。</li>
          </ul>
          <h3 id="list-features" tabindex="-1"><a class="header-anchor" href="#list-features" aria-hidden="true">#</a>
            list features</h3>
          <p>输出系统的所有功能。</p>
          <h3 id="list-libraries" tabindex="-1"><a class="header-anchor" href="#list-libraries" aria-hidden="true">#</a>
            list libraries</h3>
          <p>输出当前设备支持的所有库。</p>
          <h3 id="list-users" tabindex="-1"><a class="header-anchor" href="#list-users" aria-hidden="true">#</a> list
            users</h3>
          <p>输出系统上的所有用户。</p>
          <h3 id="path-package" tabindex="-1"><a class="header-anchor" href="#path-package" aria-hidden="true">#</a>
            path package</h3>
          <p>输出给定 package 的 APK 的路径。</p>
          <h3 id="install-options-path" tabindex="-1"><a class="header-anchor" href="#install-options-path"
              aria-hidden="true">#</a> install [options] path</h3>
          <p>将软件包（通过 path 指定）安装到系统。<br> 选项：</p>
          <ul>
            <li>-l：安装具有转发锁定功能的软件包。</li>
            <li>-r：重新安装现有应用，保留其数据。</li>
            <li>-t：允许安装测试 APK。</li>
            <li>-i installer_package_name：指定安装程序软件包名称。</li>
            <li>-s：在共享的大容量存储（如 sdcard）上安装软件包。</li>
            <li>-f：在内部系统内存上安装软件包。</li>
            <li>-d：允许版本代码降级。</li>
            <li>-g：授予应用清单文件中列出的所有权限。</li>
          </ul>
          <h3 id="uninstall-options-package" tabindex="-1"><a class="header-anchor" href="#uninstall-options-package"
              aria-hidden="true">#</a> uninstall [options] package</h3>
          <p>从系统中卸载软件包。<br> 选项：</p>
          <ul>
            <li>-k：移除软件包后保留数据和缓存目录。</li>
          </ul>
          <h3 id="clear-package" tabindex="-1"><a class="header-anchor" href="#clear-package" aria-hidden="true">#</a>
            clear package</h3>
          <p>删除与软件包关联的所有数据。</p>
          <h3 id="enable-package-or-component" tabindex="-1"><a class="header-anchor"
              href="#enable-package-or-component" aria-hidden="true">#</a> enable package_or_component</h3>
          <p>启用给定软件包或组件（作为“package/class”写入）。</p>
          <h3 id="disable-package-or-component" tabindex="-1"><a class="header-anchor"
              href="#disable-package-or-component" aria-hidden="true">#</a> disable package_or_component</h3>
          <p>停用给定软件包或组件（作为“package/class”写入）。</p>
          <h3 id="disable-user-options-package-or-component" tabindex="-1"><a class="header-anchor"
              href="#disable-user-options-package-or-component" aria-hidden="true">#</a> disable-user [options]
            package_or_component</h3>
          <p>选项：</p>
          <ul>
            <li>--user user_id：要停用的用户。</li>
          </ul>
          <h3 id="grant-package-name-permission" tabindex="-1"><a class="header-anchor"
              href="#grant-package-name-permission" aria-hidden="true">#</a> grant package_name permission</h3>
          <p>向应用授予权限。在运行 Android 6.0（API 级别 23）及更高版本的设备上，可以是应用清单中声明的任何权限。在运行 Android 5.1（API 级别
            22）和更低版本的设备上，必须是应用定义的可选权限。</p>
          <h3 id="revoke-package-name-permission" tabindex="-1"><a class="header-anchor"
              href="#revoke-package-name-permission" aria-hidden="true">#</a> revoke package_name permission</h3>
          <p>从应用中撤销权限。在运行 Android 6.0（API 级别 23）及更高版本的设备上，可以是应用清单中声明的任何权限。在运行 Android 5.1（API 级别
            22）和更低版本的设备上，必须是应用定义的可选权限。</p>
          <h3 id="set-install-location-location" tabindex="-1"><a class="header-anchor"
              href="#set-install-location-location" aria-hidden="true">#</a> set-install-location location</h3>
          <p>更改默认安装位置。位置值：</p>
          <ul>
            <li>0：自动—让系统决定最佳位置。</li>
            <li>1：内部—安装在内部设备存储上。</li>
            <li>2：外部—安装在外部介质上。</li>
          </ul>
          <blockquote>
            <p>注：此命令仅用于调试目的；使用此命令会导致应用中断和其他意外行为。</p>
          </blockquote>
          <h3 id="get-install-location" tabindex="-1"><a class="header-anchor" href="#get-install-location"
              aria-hidden="true">#</a> get-install-location</h3>
          <p>返回当前安装位置。返回值：</p>
          <ul>
            <li>0 [auto]：让系统决定最佳位置。</li>
            <li>1 [internal]：安装在内部设备存储上</li>
            <li>2 [external]：安装在外部介质上</li>
          </ul>
          <h3 id="set-permission-enforced-permission-true-false" tabindex="-1"><a class="header-anchor"
              href="#set-permission-enforced-permission-true-false" aria-hidden="true">#</a> set-permission-enforced
            permission [true|false]</h3>
          <p>指定是否应强制执行给定的权限。</p>
          <h3 id="trim-caches-desired-free-space" tabindex="-1"><a class="header-anchor"
              href="#trim-caches-desired-free-space" aria-hidden="true">#</a> trim-caches desired_free_space</h3>
          <p>减少缓存文件以达到给定的可用空间。</p>
          <h3 id="create-user-user-name" tabindex="-1"><a class="header-anchor" href="#create-user-user-name"
              aria-hidden="true">#</a> create-user user_name</h3>
          <p>使用给定的 user_name 创建新用户，输出新用户的标识符。</p>
          <h3 id="remove-user-user-id" tabindex="-1"><a class="header-anchor" href="#remove-user-user-id"
              aria-hidden="true">#</a> remove-user user_id</h3>
          <p>移除具有给定的 user_id 的用户，删除与该用户关联的所有数据。</p>
          <h3 id="get-max-users" tabindex="-1"><a class="header-anchor" href="#get-max-users" aria-hidden="true">#</a>
            get-max-users</h3>
          <p>输出设备支持的最大用户数。</p>
          <h2 id="其他命令" tabindex="-1"><a class="header-anchor" href="#其他命令" aria-hidden="true">#</a> 其他命令</h2>
          <h3 id="进行屏幕截图" tabindex="-1"><a class="header-anchor" href="#进行屏幕截图" aria-hidden="true">#</a> 进行屏幕截图</h3>
          <p>screencap 命令是一个用于对设备显示屏进行屏幕截图的 shell 实用程序。在 shell 中，此语法为：</p>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code>screencap filename
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
            </div>
          </div>
          <p>例如：</p>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code>$ <span class="token function">shell</span><span class="token punctuation">(</span><span class="token string">&quot;screencap /sdcard/screen.png&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
            </div>
          </div>
          <h3 id="列表文件" tabindex="-1"><a class="header-anchor" href="#列表文件" aria-hidden="true">#</a> 列表文件</h3>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code>ls filepath
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
            </div>
          </div>
          <p>例如:</p>
          <div class="language-javascript ext-js line-numbers-mode">
            <pre class="language-javascript"><code><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">shell</span><span class="token punctuation">(</span><span class="token string">&quot;ls /system/bin&quot;</span><span class="token punctuation">)</span><span class="token punctuation">.</span>result<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
            </div>
          </div>
        </div><!---->
        <footer class="page-meta"><!---->
          <div class="meta-item update-time"><span class="label">上次编辑于: </span><!----></div>
          <div class="meta-item contributors"><span class="label">贡献者: </span><!--[--><!--[--><span class="contributor"
              title="email: 946994919@qq.com">hyb1996</span><!--]--><!--]--></div>
        </footer>
        <nav class="page-nav"><a href="sensors.html" class="nav-link prev" aria-label="sensors - 传感器">
            <div class="hint"><span class="arrow left"></span>上一页</div>
            <div class="link"><!---->sensors - 传感器</div>
          </a><a href="storages.html" class="nav-link next" aria-label="storages - 本地存储">
            <div class="hint">下一页<span class="arrow right"></span></div>
            <div class="link">storages - 本地存储<!----></div>
          </a></nav><!----><!----><!--]-->
      </main><!--]--><!----><!--]-->
    </div><!--]--><!----><!----><!--]-->
  </div>
  <script type="module" src="../../assets/app.6aa2b576.js" defer></script>
</body>

</html>